-
Notifications
You must be signed in to change notification settings - Fork 461
removed project warnings #683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
removed project warnings #683
Conversation
@JeneaVranceanu thanks for the feedback, I have done the tasks from your feedback :) I have a doubt about swiftLint, how are you using it? I have run it via command line but I don´t know if it is the way of working or not :) |
@JeneaVranceanu did I miss something? :) |
We've actually doesn't apply it to the project yet, so this huge list of issues that you reference to is the real one for now. And about your PR, here's the deal: @JeneaVranceanu is now fighting with some important merge that brings 3.1.0 release in the game, I suppose it would take a week or two from now until he finished it. And as I suppose right after that we'll come back to your PR which is indeed important as well, but as I see no so complicated in terms of possibilities of breaking something of conflicts would be appeared whilst merging. |
Thanks for the clarification @yaroslavyaroslav :) |
@albertopeam please resolve conflicts and we will review again. Same for #688 |
282ef52
to
1381c98
Compare
@janndriessen ready to review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! It was already well reviewed before by @JeneaVranceanu too. Last changes were just about merge conflicts. ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm back and within next week highly likely will review all prs.
extension Array where Element == Any? { | ||
func toAnyObject() -> [AnyObject] { | ||
self.map { $0 as AnyObject } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could fail, since Any is more broad that AnyObject is, so the casting could fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see how this can cause problems. @yaroslavyaroslav Could you please give more explanation/examples?
It's said that all classes implicitly conform to AnyObject
but we're able to cast structs as well so maybe that part about structs (or to be specific value types
is confusing).
Did some research and found that casting value types to AnyObject
produces a wrapper of type __SwiftValue
. And here is the __SwiftValue
. Look at the docs on line 13.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, why did they do that? Like now there's completely no difference between Any
and AnyObject
isn't it? If so, i agree that this would not fall, but i still suggest to make that extension more consistent, using either Any
or AnyObject
in whole method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still some difference when it comes to casting back to the original type. I cannot explain that in detail but for example if we cast UInt64(1)
to AnyObject
and try to use it as if let bool = uint64AsAnyObject as? Bool
it will successfully cast to Bool
. But if you cast it to Any
instead it will cast back only as UInt64
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but for example if we cast UInt64(1) to AnyObject and try to use it as if let bool = uint64AsAnyObject as? Bool it will successfully cast to Bool. But if you cast it to Any instead it will cast back only as UInt64.
Actually I'd consider this as a bug of those thing that is casting to AnyObject for Objective-C environment. But I don't sure though.
// MARK: - Conversion | ||
|
||
/// Transforms `[Any?]` into `[AnyObject]` | ||
extension Array where Element == Any? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This extension doesn't apply to
[Any]
but it should. As a solutionwhere
clause can be removed; - I'd suggest renaming the function to
toAnyObjectArray
; - Why
self.map { ... }
and not justas [AnyObject]
?
This is the suggested update:
/// Transforms into `[AnyObject]`
extension Array {
func toAnyObjectArray() -> [AnyObject] {
self as [AnyObject]
}
}
The warnings this PR fixes: